#ifndef _SCAN_BUFFERBLOCK_INCLUDE
#define _SCAN_BUFFERBLOCK_INCLUDE

#include "ScanBuffer.h"

class BufferBlock {

	// position in array "block"
	unsigned int pos;
	char* block;
	
	// size of the array
	unsigned int size;
	
	// if we have the end of file in this block, this var keeps the position of the last character. otherwise ist null.
	unsigned int eof_pos; 

	// typical list pointers
	BufferBlock* nextBlock;
	BufferBlock* prevBlock;

	
public:
	/**
	* Constructor.
	*
	* @param size Size of this block.
	* @param block The array of chars.
	* @param eof_pos The position of the end of file in this array. 0 if the end is not in this block.
	*
	*/
	BufferBlock(int size, char* block, int eof_pos=0);
	~BufferBlock();

	
	/**
	* Returns the next char in this block.
	* @return Next char of this block.
	*/
	char getNextChar();
	
	/**
	* Returns the status of this block.
	* @return The position of the pointer.
	* -1 = at position 0.
	* 0 = somewhere in the middle.
	* 1 = at the end. (pos == size)
	*/
	int getStatus();
	
	/**
	* Rewinds the position pointer with a definable amount of steps.
	* @param count Amount of steps.
	* @return The BufferBlock where the global (ScanBufferList-) positionpointer points to.
	*/
	BufferBlock* rewindChars(int count);

	
	void setNextBlock(BufferBlock* block);
	void setPrevBlock(BufferBlock* block);
	BufferBlock* getNextBlock();
	BufferBlock* getPrevBlock();
};

#endif
